<template>
  <div>
    <vm-common-header
      :pageTitle="pageTitle"
      :goBack="goBack"></vm-common-header>
    <div class="vm-common-work_bench container">
      <mt-loadmore
        :top-method="loadTop"
        :bottom-method="loadBottom"
        :bottom-all-loaded="allLoaded"
        ref="loadmore"
        :autoFill="false">
        <swipeout>
          <swipeout-item
            ref="swipeoutItem"
            :right-menu-width="30"
            :sensitivity="15"
            v-for="(item, key) in allbidsData"
            :key="key"
            :auto-close-on-button-click="false">
            <div slot="content" class="demo-content vux-1px-b">
              <ul>
                <li ref="oli" class="mui-selected vm-work_bench-item mui-table-view-cell">
                  <router-link class="mui-slider-handle" tag="div" :to="`/common_details/${item.ID}/采购公告详情`">
                    <h5 class="vm-work_bench-item-title">
                      <h3>{{ item.cIBidsTatle }}</h3>
                      <x-icon type="ios-arrow-right" size="22"></x-icon>
                    </h5>
                    <div class="vm-work_bench-item-body">
                      <div>
                        <span>责任人：</span>
                        <em>{{ item.cRealName }}</em>
                      </div>
                      <div>
                        <span>公告期：</span>
                        <em>{{ item.iAnnDay }}天</em>
                      </div>
                      <div style="width: 100%;">
                        <span>开标时间：</span>
                        <em>{{ item.dOpenTime }}</em>
                      </div>
                    </div>
                  </router-link>
                </li>
              </ul>
            </div>
          </swipeout-item>
        </swipeout>
        <vm-common-noData v-if="!allbidsData.length"></vm-common-noData>
      </mt-loadmore>
    </div>

  </div>
</template>

<script>
  import vmCommonHeader from '@/components/vm-common-header' // header 组件
  import {Swipeout, SwipeoutItem, SwipeoutButton} from 'vux'
  import {MessageBox} from 'mint-ui'
  import { bid_allbidslist } from '@/api/work_bench.js'
  export default {
    data() {
      return {
        pageTitle: this.$route.meta.pageTitle, // page标题
        goBack: this.$route.meta.goBack, // 是否返回
        allbidsData: new Array(),
        tempListData: new Array(),
        tempIndex: null,
        planListPage: 1, //当前页数
        allLoaded: false, // 是否还有数据
        examineStatus: false,
        reasonData: '', // 审批内容
        isActive1: false,
        isActive2: false
      }
    },
    created() {
      this.getallbidsData();
    },
    methods: {
      // 获取需求计划数据
      getallbidsData(loadmoreType) {
        let planListPage = this.planListPage;
        bid_allbidslist(planListPage).then(res => {
          if (!res.data.data.length) {
            this.allLoaded = true; // 若数据已全部获取完毕
          }
          if (!this.allbidsData.length || planListPage == 1) {
            this.allLoaded = false;
            this.allbidsData = res.data.data;
          } else {
            this.allbidsData = this.allbidsData.concat(res.data.data);
          }
          console.log(this.allbidsData);
          if (loadmoreType == 'top') {
            this.$refs.loadmore.onTopLoaded();
          } else {
            this.$refs.loadmore.onBottomLoaded();
          }
        })
      },
      // 下拉刷新
      loadTop() {
        this.allbidsPage = 1;
        this.getallbidsData('top');
      },
      // 上拉加载
      loadBottom() {
        this.allbidsPage ++;
        this.getallbidsData('bottom');
      }
    },
    components: {
      'vm-common-header': vmCommonHeader,
      Swipeout,
      SwipeoutItem,
      SwipeoutButton
    },
    watch: {
      examineStatus (newV) {
        if (!newV) {
          for ( let o of this.$refs.swipeoutItem) {
            o.close();
          }
        }
      }
    }
  }
</script>

<style scoped lang="scss">

</style>
